
struct QSOUND_CHANNEL
{
	INT32 bank;	   /* bank (x16)    */
	INT32 address;	/* start address */
	INT32 pitch;	  /* pitch */
	INT32 reg3;	   /* unknown (always 0x8000) */
	INT32 loop;	   /* loop address */
	INT32 end;		/* end address */
	INT32 vol;		/* master volume */
	INT32 pan;		/* Pan value */
	INT32 reg9;	   /* unknown */

	/* Work variables */
	INT32 key;		/* Key on / key off */

	INT32 lvol;	   /* left volume */
	INT32 rvol;	   /* right volume */
	INT32 lastdt;	 /* last sample value */
	INT32 offset;	 /* current offset counter */
};

class CQSoundChannel {
	private:
			INT32 bank;	   /* bank (x16)    */
			INT32 address;	/* start address */
			INT32 pitch;	  /* pitch */
			INT32 reg3;	   /* unknown (always 0x8000) */
			INT32 loop;	   /* loop address */
			INT32 end;		/* end address */
			INT32 vol;		/* master volume */
			INT32 pan;		/* Pan value */
			INT32 reg9;	   /* unknown */

			/* Work variables */
			INT32 key;		/* Key on / key off */

			INT32 lvol;	   /* left volume */
			INT32 rvol;	   /* right volume */
			INT32 lastdt;	 /* last sample value */
			INT32 offset;	 /* current offset counter */
	public:
		void Write		 (UINT8 data);
		void RenderSample(CAudioBuffer* left, CAudioBuffer* right);
};

class CQSound : public CBaseSoundDevice {
	private:
		int locked; // Set to 1 if a ROM isn't assigned.
		CQSoundChannel channel[16];
		int data;				  /* register latch data */
		CMemory* sample_rom;
		UINT32 sample_rom_length;

		int pan_table[33];		 /* Pan volume table */
		float frq_ratio;		   /* Frequency ratio */

		CAudioBuffer* outputs[2];
	public:
		int   Buffer(short**, int);
		UINT8 Read(UINT64);
		void  Write(UINT64, UINT8);
		int GetRomSlotCount();
		void SetRom(int slot, CMemory* rom);
		int Init(int sr, unsigned int clock); // Leaving this virtual for other chips using the same code (YM2149)
		void Reset();
		void Shutdown();
};